/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/RectangleShape.h"


namespace TD_Core {

	/************************************************************************/
	/* Constructors                                                         */
	/************************************************************************/
	RectangleShape::RectangleShape() {

	}

	RectangleShape::RectangleShape(const TD_Core::RectangleShape &rhs) {
		m_boundaries = rhs.getBoundaries();
	}

	RectangleShape & RectangleShape::operator=(const RectangleShape & rhs) {
		m_boundaries = rhs.getBoundaries();
		return(*this);
	}

	RectangleShape::RectangleShape(const Coord2D &position, const Coord2D &size) {
		m_position = position;
		m_boundaries = size;
	}
	RectangleShape::~RectangleShape() {
		std::cout << "Never know how much A love you" << std::endl;
	}

	/************************************************************************/
	/* Functionalities                                                      */
	/************************************************************************/
	bool RectangleShape::collisionCheck(BaseShape *other) {
		RectangleShape *otherRectangle = dynamic_cast<RectangleShape *>(other);
		if(otherRectangle) { 
			/**Considering the SDL coordinate system:*/
			if(this->getRightBottomCorner().y <= otherRectangle->getLeftTopCorner().y) {
				return false;
			} else if (this->getLeftTopCorner().y >= otherRectangle->getRightBottomCorner().y) {
				return false;
			} else if (this->getRightBottomCorner().x <= otherRectangle->getLeftTopCorner().x) {
				return false;
			} else if (this->getLeftTopCorner().x >= otherRectangle->getRightBottomCorner().x) {
				return false;
			}
			return true;
		}
		/************************************************************************/
		/* IMPLEMENT FOR SPHERES:                                               */
		/************************************************************************/
		return false;
	}

	bool RectangleShape::collisionCheck(const Coord2D &position) {
		if(getRightBottomCorner().y >= position.y && getRightBottomCorner().x >= position.x 
			&& getLeftTopCorner().y <= position.y && getLeftTopCorner().x <= position.x) {
			return true;
		} 
		return false;
	}
}